
#include "lvgl.h"
#include "md_images.h"
#include "md_ui_def.h"


/*********************************func图标数据**************************************/
LV_IMG_DECLARE(ac_control);        
LV_IMG_DECLARE(ai_chat);
LV_IMG_DECLARE(ammeter);
LV_IMG_DECLARE(ble_speaker);
LV_IMG_DECLARE(calculator);
LV_IMG_DECLARE(dac_fx);
LV_IMG_DECLARE(download);
LV_IMG_DECLARE(location);
LV_IMG_DECLARE(logic_analyzer);
LV_IMG_DECLARE(minigame);
LV_IMG_DECLARE(music);
LV_IMG_DECLARE(oscilloscope);
LV_IMG_DECLARE(OTA);
LV_IMG_DECLARE(pd);
LV_IMG_DECLARE(pwm);
LV_IMG_DECLARE(setting);
LV_IMG_DECLARE(stopwatch);
LV_IMG_DECLARE(usb_aux_screen);
LV_IMG_DECLARE(video);
LV_IMG_DECLARE(voice_recorder);
LV_IMG_DECLARE(wired_debug);
LV_IMG_DECLARE(wireless_debug);
LV_IMG_DECLARE(wifi_icon);
LV_IMG_DECLARE(sd_card);
LV_IMG_DECLARE(astronaut_spins);
LV_IMG_DECLARE(image);
LV_IMG_DECLARE(txt);
LV_IMG_DECLARE(bilibili);

static const void *image_data[FUNC_MAX] = {
    /*******调试工具*********/
    [FUNC_LOGIC_ANALYZER] = &logic_analyzer,
    [FUNC_WIRELESS_DEBUG] = &wireless_debug,
    [FUNC_WIRED_DEBUG] = &wired_debug, //
    [FUNC_USB_WIFI_SD] = &sd_card,     //

    /*******信号仪器*********/
    [FUNC_PWM_OUTPUT] = &pwm,
    [FUNC_DAC_WAVEFORM] = &dac_fx,
    [FUNC_AMMETER] = &ammeter,
    [FUNC_OSCILLOSCOPE] = &oscilloscope,
    [FUNC_PD_OUTPUT] = &pd,

    /*******多媒体功能*********/
    [FUNC_VIDEO_PLAYER] = &video,
    [FUNC_MUSIC_PLAYER] = &music,
    [FUNC_IMAGE_PLAYER] = &image,
    [FUNC_VOICE_RECORDER] = &voice_recorder,
    [FUNC_BLE_SPEAKER] = &ble_speaker,

    /*******实用小工具*********/
    [FUNC_STOPWATCH] = &stopwatch,
    [FUNC_CALCULATOR] = &calculator,
    [FUNC_IP_LOCATION] = &location,
    [FUNC_OFFLINE_DOWNLOAD] = &download,
    [FUNC_AC_CONTROL] = &ac_control,
    [FUNC_USB_AUX_SCREEN] = &usb_aux_screen,

    /*******娱乐功能*********/
    [FUNC_MINIGAME] = &minigame,
    [FUNC_TXT_READER] = &txt,
    [FUNC_BILIBILI] = &bilibili,
    [FUNC_AI_CHAT] = &ai_chat,

    /*******系统配置*********/
    [FUNC_SYSTEM_SETTINGS] = &setting,
    [FUNC_WIFI_SETTINGS] = &wifi_icon,

    [FUNC_OTA_UPDATE] = &OTA,
};

void *get_func_icon_data(func_category_t func_category, uint8_t num)
{
    //防御性编程，如果传入的分类超出范围，则返回空指针
    if (func_category >= CAT_MAX || func_category < 0)
        return NULL;

    uint16_t index = 0;

    for (int i = 0; i < func_category; i++) {
        index += get_func_cat_count(i);
    }
    if (num>=get_func_cat_count(func_category))
        num = get_func_cat_count(func_category);
        
    index += num;
    return image_data[index];
}
/*********************************func图标数据 END**************************************/

/*********************************func内部图片数据**************************************/
/***************逻辑分析仪****************/
LV_IMG_DECLARE(libsigrok_112x112);
//LV_IMG_DECLARE(img_src_pin_logicanalyzer);
/******************DAP-Link***************/
//LV_IMG_DECLARE(img_src_dap_connected);
/******************Settings****************/
LV_IMG_DECLARE(lang_switch);
LV_IMG_DECLARE(screen_color);
LV_IMG_DECLARE(bright);
LV_IMG_DECLARE(voice_control);
LV_IMG_DECLARE(screenshot);
LV_IMG_DECLARE(factory_reset);
LV_IMG_DECLARE(author);
LV_IMG_DECLARE(entrance);
LV_IMG_DECLARE(pvz_map);
/******************游戏图片****************/
LV_IMG_DECLARE(jump2jump)
LV_IMG_DECLARE(icon_2048)
LV_IMG_DECLARE(match_3png)
LV_IMG_DECLARE(pvz_icon)
LV_IMG_DECLARE(chess)
LV_IMG_DECLARE(cut_melon)
LV_IMG_DECLARE(dice)
LV_IMG_DECLARE(flappybird)

/******************空调****************/
LV_IMG_DECLARE(ac_fan)
LV_IMG_DECLARE(ac_mode)
LV_IMG_DECLARE(ac_power)
LV_IMG_DECLARE(ac_temp)
LV_IMG_DECLARE(ac_type)
/******************有线调试****************/
LV_IMG_DECLARE(arm_icon)
LV_IMG_DECLARE(esp_icon)
/******************B站****************/
LV_IMG_DECLARE(bilibili_logo)
LV_IMG_DECLARE(bilibili_name)

/*
 *@brief:获取对应功能界面的图片数据
 *@param:func_type:功能类型
 *        num:功能序号
 *@return:对应图片数据
 */
const void *get_func_image_data(func_list_t func_type, uint8_t num)
{
    // if (func_type >= FUNC_MAX && func_type > 0)
    //     return NULL;

    switch (func_type) {
        case FUNC_LOGIC_ANALYZER: // 逻辑分析仪
            switch (num) {
                case LOGIC_ANALYZER_NUM:
                    return &libsigrok_112x112;
            }
            break;
        case FUNC_WIRELESS_DEBUG: // 无线调试
            break;
        case FUNC_WIRED_DEBUG: // 有线调试
            if (WIRED_DEBUG_DAP_NUM == num)
                return &arm_icon;
            else if (WIRED_DEBUG_ESP_NUM == num)
                return &esp_icon;
            break;
        case FUNC_PWM_OUTPUT: // PWM输出
            break;
        case FUNC_DAC_WAVEFORM: // DAC波形
            break;
        case FUNC_AMMETER: // 电流表
            break;
        case FUNC_OSCILLOSCOPE: // 示波器
            break;
        case FUNC_PD_OUTPUT: //(PD输出)
            break;
        case FUNC_STOPWATCH: // 秒表
            break;
        case FUNC_CALCULATOR: // 计算器
            break;
        case FUNC_IP_LOCATION: //(IP 定位 / 天气）
            break;
        case FUNC_OFFLINE_DOWNLOAD: //（离线下载）
            break;
        case FUNC_AC_CONTROL: //（空调遥控 / RMT 控制）
                              /*因为不多就不单独创一个文件了*/
            switch (num) {
                case AC_DEVICE_TYPE_NUM:
                    return &ac_type;
                case AC_TEMP_NUM:
                    return &ac_temp;
                case AC_POWER_NUM:
                    return &ac_power;
                case AC_MODE_NUM:
                    return &ac_mode;
                case AC_FAN_NUM:
                    return &ac_fan;
                // case AC_SEND_NUM:
                //     return &;
                default:
                    break;
            }
            break;
        case FUNC_USB_AUX_SCREEN: //（USB 副屏）
            break;
        case FUNC_VIDEO_PLAYER: // 视频播放
            break;
        case FUNC_MUSIC_PLAYER: // 音乐播放
            break;
        case FUNC_VOICE_RECORDER: // 录音机
            break;
        case FUNC_BLE_SPEAKER: //Ble 音箱
            break;
        case FUNC_MINIGAME: //（小游戏：2048、骰子等）
            switch ((game_type_t)num) {
                case GAME_JUMP2JUMP://跳一跳
                    /* code */
                    return &jump2jump;
                case GAME_2048://2048
                    /* code */
                    return &icon_2048;
                case GAME_MATCH3://消消乐
                    /* code */
                    return &match_3png;
                case GAME_PVZ://植物大战僵尸
                    /* code */
                    return &pvz_icon;
                case GAME_CHESS://象棋
                    /* code */
                    return &chess;
                case GAME_CUT_MELON://切西瓜
                    /* code */
                    return &cut_melon;
                case GAME_DICE://骰子
                    /* code */
                    return &dice;
                case GAME_FLAPPYBIRD://Flappy Bird
                    /* code */
                    return &flappybird;
                default:
                    break;
            }
            break;
        case FUNC_BILIBILI: // B站
            if (BILIBILI_LOGO_NUM == num) {
                return &bilibili_logo;
            } else if (BILIBILI_NAME_NUM == num) {
                return &bilibili_name;
            }
            break;
        case FUNC_AI_CHAT: // AI对话

            break;

        case FUNC_SYSTEM_SETTINGS: // 系统设置
            switch (num) {
                case SETTINGS_LANG_NUM:
                    return &lang_switch;
                case SETTINGS_BRIGHT_NUM:
                    return &screen_color;
                case SETTINGS_SCREEN_COLOR_NUM:
                    return &bright;
                case SETTINGS_VOICE_CONTROL_NUM:
                    return &voice_control;
                case SETTINGS_SCREENSHOT_CONTROL_NUM:
                    return &screenshot;
                case SETTINGS_FACTORY_RESET_NUM:
                    return &factory_reset;
                case SETTINGS_AUTHOR_NUM:
                    return &author;
                case SETTINGS_AUTHOR_ENTR_NUM:
                    return &entrance;
                }
            break;
        case FUNC_OTA_UPDATE: // OTA更新
            break;
        default:
            break;
    }

    return NULL;
}
/*********************************func内部图片数据 END**************************************/
/*********************************获取gif图片数据 **************************************/
const void *get_gif_data(uint8_t num)
{
    switch (num) {
        case 0:
            return &astronaut_spins;
        default:
            return NULL;
    }
}
    /*********************************获取gif图片数据 END**************************************/
